package com.bk.game.mc;

import com.badlogic.gdx.graphics.g2d.Sprite;
import com.badlogic.gdx.graphics.g2d.SpriteBatch;
import com.badlogic.gdx.graphics.g2d.TextureRegion;
import com.badlogic.gdx.scenes.scene2d.Actor;
import com.badlogic.gdx.utils.Disposable;
import com.bk.game.global.BkGlobal;
import com.bk.game.screen.GameScreen;

public class StartBtn extends Actor implements Disposable {

	private Sprite sprite;
	private float scaleX, scaleY;

	private float x, y;

	public StartBtn(TextureRegion region, float left, float top) {
		sprite = new Sprite(region);
		scaleX = 228 * BkGlobal.factorx;
		scaleY = 228 * BkGlobal.factory;
		sprite.setSize(scaleX, scaleY);
		this.x = left * BkGlobal.factorx;
		this.y = top * BkGlobal.factory;
		sprite.setColor(0, 0, 0, 0);
		sprite.setPosition(this.x, this.y);
	}

	@Override
	public void dispose() {

	}

	@Override
	public void draw(SpriteBatch spriteBatch, float arg1) {
		sprite.draw(spriteBatch);
	}

	@Override
	public Actor hit(float arg0, float arg1) {
		if (arg0 > x && arg1 > y && arg0 < x + sprite.getWidth() && arg1 < y + sprite.getHeight()) {
			return this;
		}
		return null;
	}

	@Override
	public boolean touchDown(float x, float y, int pointer) {
		BkGlobal.btnSound.play();
		sprite.setColor(0.2f, 0.2f, 0.2f, 0.8f);
		return true;
	}

	@Override
	public void touchDragged(float x, float y, int pointer) {
		super.touchDragged(x, y, pointer);
	}

	@Override
	public boolean touchMoved(float x, float y) {
		return super.touchMoved(x, y);
	}

	@Override
	public void touchUp(float x, float y, int pointer) {
		sprite.setColor(0, 0, 0, 0);
		if (BkGlobal.gameScreen == null) {
			BkGlobal.gameScreen = new GameScreen();
		}
		BkGlobal.currentGame.setScreen(BkGlobal.gameScreen);
	}

}
